﻿using System;
using System.Collections.Generic;
using DC2010.Objects.Base;
using System.Xml.Serialization;
using DC2010.Objects.Common;

namespace DC2010.Objects.Data
{
    [Serializable]
    public class PartyInfo : BaseInfo
    {
        public PartyInfo()
        {
            MembersData = new List<CreatureData>();
            Members = new List<string>();
            Formation = new List<DungeonPlacement>();
            Location = new DungeonLoc();
        }

        /// <summary>
        /// Id of this party leader
        /// </summary>
        public string PartyLeaderId { get; set; }

        /// <summary>
        /// Members
        /// </summary>
        [XmlIgnore]
        public List<CreatureData> MembersData { get; set; }

        public List<string> Members { get; set; }

        public List<DungeonPlacement> Formation { get; set; }

        public int Max { get; set; }

        public DungeonLoc Location { get; set; }

        /// <summary>
        /// Each creature in this party has its own position. 
        /// 
        /// facing north
        /// 
        /// 0 | 1
        /// -----
        /// 3 | 2
        /// 
        /// facing east
        /// 
        /// 3 | 0
        /// -----
        /// 2 | 1
        /// 
        /// simply low indexed monsters are in front lines.
        /// </summary>
        public List<KeyValue> IndexedCreatures { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public Directions Facing { get; set; }



        public PartyData CreateData()
        {
            PartyData cd = new PartyData();

            cd.InfoId = Id;
            cd.Id = cd.InfoId + "_" + Guid.NewGuid().ToString();
            cd.Location = (DungeonLoc)Location.Clone();
            //TODO: fill with other properties
            Root.log.InfoFormat("Core, Created new object with id: {0} based on object {1}", cd.Id, cd.InfoId);
            Root.I.PartySystem.AddData(cd);



            return cd;
        }


    }
}
